package main

import (
	"fmt"
	"unsafe"
)

//获取变量占用内存大小
func GetVarSize() {
	records := make([]int, 0, 100)
	fmt.Println("begin Size of []int32:", unsafe.Sizeof(records))
	for i := 1; i < 10000000; i++ {
		records = append(records, i)
		if len(records) > 100 {
			records = updateFreqInfo(records)
			fmt.Println("Size of []int32:", unsafe.Sizeof(records), i, cap(records))
		}
	}

}

func updateFreqInfo(record []int) []int {
	return record[:0]
}
